package com.example.ResumeWorkPlatform.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;


/**
 * @ClassName: BasicUserDao
 * @Description: 基本人员 BasicUserDao
 * @Author chengwenixng
 * @DateTime 2021-3-25
 */
@Repository
public interface BasicUserDao  extends JpaRepository<BasicUserEntity,Long>{

	/**
	 * @Title:  findByAccountAndDelFlag
	 * @Description: 根据账号查找
	 * @Author chengwenixng
	 * @DateTime 2021-3-21
	 * @param email
	 * @param delFlag
	 * @return
	 */
	BasicUserEntity findByAccountAndDelFlag(String account,boolean delFlag);
	/**
	 * @Title:  findByPhoneAndDelFlag
	 * @Description: 根据手机号和是否删除查询数据
	 * @Author chengwenixng
	 * @DateTime 2021-3-21
	 * @param email
	 * @param delFlag
	 * @return
	 */
	BasicUserEntity findByPhoneAndDelFlag(String phone,boolean delFlag);
	/**
	 * @Title: findByDelflag 
	 * @Description: 根据是否删除获取数据
	 * @Exception: 
	 * @Author chengwenxing
	 * @DateTime 2021-03-20 13:35:01 
	 * @param delflag
	 * @return BasicUserEntity
	 */
	List<BasicUserEntity> findByDelFlag(boolean delFlag);

	/**
	 * 
	 * @Title: findByIdAndDelFlag
	 * @Description: 根据ID和删除标识查找
	 * @param studentname
	 * @DateTime 2021-03-20 13:35:01 
	 * @param id
	 * @param delFlag
	 * @return
	 */
	BasicUserEntity findByIdAndDelFlag(Long id,boolean delFlag);
	/**
	 * 根据工业园区id查询今日打卡人员信息
	 */
	@Query(value = "SELECT * FROM basic_user_entity WHERE gerden_entity_id= ?1 AND  del_flag = TRUE AND is_work = TRUE AND is_rturn_working_location = TRUE AND finish_insulate = TRUE AND work_resumption= TRUE", nativeQuery = true)
	List<BasicUserEntity> getTodayBasicUserLists(Long id);
	/**
	 * 根据id工业园区查询今日健康人员信息
	 */
	@Query(value = "SELECT * FROM basic_user_entity WHERE gerden_entity_id= ?1 AND  del_flag = TRUE AND is_health = TRUE ", nativeQuery = true)
	List<BasicUserEntity> findByIdAndisHealth(Long id);
	/**
	 * 根据工业园区id查询今日健康并打卡人员信息
	 */
	@Query(value = "SELECT * FROM basic_user_entity WHERE gerden_entity_id= ?1 AND  del_flag = TRUE AND is_health = TRUE AND is_work = TRUE AND is_rturn_working_location = TRUE AND finish_insulate = TRUE AND work_resumption= TRUE", nativeQuery = true)
	List<BasicUserEntity> findByIdAndisHealthAndIsWork(Long id);
	/**
	 * 根据工业园区id查询已完成隔离人员信息
	 */
	@Query(value = "SELECT * FROM basic_user_entity WHERE gerden_entity_id= ?1 AND  del_flag = TRUE AND finish_insulate = TRUE ", nativeQuery = true)
	List<BasicUserEntity> findByIdAndFinishInsulate(Long id);
	/**
	 * 根据工业园区id查询隔离中
	 */
	@Query(value = "SELECT * FROM basic_user_entity WHERE gerden_entity_id= ?1 AND  del_flag = TRUE AND finish_insulate = FALSE", nativeQuery = true)
	List<BasicUserEntity> findByIdAndIsFinishInsulate(Long id);
	
	/**
	 * 根据工业园区id查询已复工
	 */
	@Query(value = "SELECT * FROM basic_user_entity WHERE gerden_entity_id= ?1 AND  del_flag = TRUE AND work_resumption= TRUE", nativeQuery = true)
	List<BasicUserEntity> findByIdAndworkResumption(Long id);
	/**
	 * 根据工业园区id查询回工作地
	 */
	@Query(value = "SELECT * FROM basic_user_entity WHERE gerden_entity_id= ?1 AND  del_flag = TRUE AND is_rturn_working_location = TRUE", nativeQuery = true)
	List<BasicUserEntity> findByIdAndRturnWorkingLocation(Long id);
	/**
	 * 根据工业园区id查询有疫区接触史
	 */
	@Query(value = "SELECT * FROM basic_user_entity WHERE gerden_entity_id= ?1 AND  del_flag = TRUE AND is_touch = TRUE ", nativeQuery = true)
	List<BasicUserEntity> findByIdAndTouch(Long id);

	
	
}
 